/*
 * DrawingCanvas.cpp
 *
 *  Created on: Jul 1, 2009
 *      Author: kurt
 */

#include "DrawingCanvas.h"
#include <GL/gl.h>

#include <sstream>
#include <iostream>
using namespace std;
using namespace objdraw;

DrawingCanvas::~DrawingCanvas() 
{
	
}
DrawingCanvas::DrawingCanvas() 
{
	start = Location(0,0);
	width = 480; height = 272;
	cmanager = CanvasManager();
}
CanvasManager& DrawingCanvas::getCanvasContent() { return cmanager; }
float DrawingCanvas::getHeight() { return height; }
float DrawingCanvas::getWidth() { return width; }
float DrawingCanvas::getX() { return start.getX(); }
float DrawingCanvas::getY() { return start.getY(); }
Location DrawingCanvas::getLocation() { return start; }
void DrawingCanvas::move(float dx, float dy) { start.translate(dx,dy); }
void DrawingCanvas::moveTo(float x, float y) { start.moveTo(x,y); }
void DrawingCanvas::moveTo(Location point) { start = point; }
void DrawingCanvas::repaint()
{
	list<DrawableInterface *>::iterator it;
	for(it = cmanager.begin();
		it != cmanager.end();
		it++)
	{
		(**it).render();
	}
}
void DrawingCanvas::clearScreen(Color c)
{
	c.useClearColor();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void DrawingCanvas::clearScreen()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

string DrawingCanvas::toString()
{
	stringstream rstr("DrawingCanvas: ");
	rstr << 
	"width = " << width << 
	"; height = " << height << 
	"; start = " << start.toString() << 
	" cmanager = " << cmanager.toString();
	
	return rstr.str();
}
